package com.april.pattern.creational.singleton;

/**
 * @author April
 * @version V1.0.0
 * @date 2019/06/23 11:20
 * @description 基于ThreadLocal的单例：对于一个线程获取的对象是单例的
 */
public class ThreadLocalInstance {
    private static final ThreadLocal<ThreadLocalInstance> THREAD_LOCAL_INSTANCE =
            ThreadLocal.withInitial(ThreadLocalInstance::new);

    private ThreadLocalInstance() {

    }

    public static ThreadLocalInstance getInstance() {
        return THREAD_LOCAL_INSTANCE.get();
    }
}
